package com.suao.web.controller.fruits;

import com.suao.common.annotation.Log;
import com.suao.common.core.controller.BaseController;
import com.suao.common.core.domain.AjaxResult;
import com.suao.common.core.page.TableDataInfo;
import com.suao.common.enums.BusinessType;
import com.suao.common.utils.poi.ExcelUtil;
import com.suao.fruits.domain.FruitsStockInfo;
import com.suao.fruits.service.IFruitsStockInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 水果入库管理Controller
 *
 * @author suao
 * @date 2023-03-08
 */
@RestController
@RequestMapping("/fruits/FruitsStockInfo")
public class FruitsStockInfoController extends BaseController
{
    @Autowired
    private IFruitsStockInfoService fruitsStockInfoService;

    /**
     * 查询水果入库管理列表
     */
    @PreAuthorize("@ss.hasPermi('fruits:FruitsStockInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(FruitsStockInfo fruitsStockInfo)
    {
        startPage();
        List<FruitsStockInfo> list = fruitsStockInfoService.selectFruitsStockInfoList(fruitsStockInfo);
        return getDataTable(list);
    }

    /**
     * 导出水果入库管理列表
     */
    @PreAuthorize("@ss.hasPermi('fruits:FruitsStockInfo:export')")
    @Log(title = "水果入库管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FruitsStockInfo fruitsStockInfo)
    {
        List<FruitsStockInfo> list = fruitsStockInfoService.selectFruitsStockInfoList(fruitsStockInfo);
        ExcelUtil<FruitsStockInfo> util = new ExcelUtil<FruitsStockInfo>(FruitsStockInfo.class);
        util.exportExcel(response, list, "水果入库管理数据");
    }

    /**
     * 获取水果入库管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('fruits:FruitsStockInfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(fruitsStockInfoService.selectFruitsStockInfoById(id));
    }

    /**
     * 新增水果入库管理
     */
    @PreAuthorize("@ss.hasPermi('fruits:FruitsStockInfo:add')")
    @Log(title = "水果入库管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FruitsStockInfo fruitsStockInfo)
    {
        return toAjax(fruitsStockInfoService.insertFruitsStockInfo(fruitsStockInfo));
    }

    /**
     * 修改水果入库管理
     */
    @PreAuthorize("@ss.hasPermi('fruits:FruitsStockInfo:edit')")
    @Log(title = "水果入库管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FruitsStockInfo fruitsStockInfo)
    {
        return toAjax(fruitsStockInfoService.updateFruitsStockInfo(fruitsStockInfo));
    }

    /**
     * 删除水果入库管理
     */
    @PreAuthorize("@ss.hasPermi('fruits:FruitsStockInfo:remove')")
    @Log(title = "水果入库管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fruitsStockInfoService.deleteFruitsStockInfoByIds(ids));
    }
}
